﻿using System;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.Web.UI;
using System.Reflection;
using System.ComponentModel;

using Developmentalmadness.Web.UI.AjaxAbstractions;

namespace Developmentalmadness.Web.UI.ExtJsControlLibrary
{
    public class ExtJsMenuColorItem : ExtJsMenuAdapter
    {
        private List<ScriptReference> _references = new List<ScriptReference>();

        public override List<ScriptReference> GetScriptReferences()
        {
            _references.AddRange(base.GetScriptReferences());

            return _references;
        }

        public override IList<ScriptDescriptor> GetScriptDescriptors()
        {
            IList<ScriptDescriptor> list = base.GetScriptDescriptors();

            ScriptControlDescriptorBase desc = (ScriptControlDescriptorBase)list[0];

            desc.Type = "Ext.menu.ColorItem";

            // date picker
            if (palette != null)
            {
                ScriptControlDescriptorBase descriptor = (ScriptControlDescriptorBase)palette.GetScriptDescriptors()[0];

                _references.AddRange(palette.GetScriptReferences());

                desc.AddPropertyBase("palette", descriptor.WriteScript(ScriptType.ConfigOnly));
            }
            return list;
        }


        #region Public Properties

        [PersistenceMode(PersistenceMode.InnerProperty)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public ExtJsColorPalette palette { get; set; }

        #endregion

    }
}
